import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:whale/helper/utils/util.dart';
import 'package:whale/pages/im/model/im_list.dart';

import '../index.dart';

/// hello
class ImListCell extends GetView<ImListController> {
  const ImListCell({
    Key? key,
    required this.md,
    this.onTap,
  }) : super(key: key);
  final ImListModel md;
  final VoidCallback? onTap;
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      child: Container(
        color: Colors.white,
        padding: EdgeInsets.symmetric(horizontal: 10.r, vertical: 10.r),
        child: Column(
          children: [
            Row(
              children: [
                RedDotContainer(
                  // dotSize: 50.r,
                  isRead: md.msg.isRead,
                  child: loadImage(
                    url: md.fromUser.avater,
                    width: 40.r,
                    height: 40.r,
                    fit: BoxFit.contain,
                  ),
                ),
                Container(
                  width: 10.r,
                ),
                Expanded(
                  child: Container(
                    alignment: Alignment.centerLeft,
                    height: 50.r,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Expanded(
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              Container(
                                alignment: Alignment.centerLeft,
                                height: 20.r,
                                child: Text(
                                  md.fromUser.name,
                                  style: TextStyle(
                                    color: const Color(0xff333333),
                                    fontSize: 14.sp,
                                  ),
                                ),
                              ),
                              Container(
                                alignment: Alignment.centerLeft,
                                height: 20.r,
                                child: Text(
                                  md.msg.content,
                                  maxLines: 1,
                                  overflow: TextOverflow.ellipsis,
                                  style: TextStyle(
                                    color: const Color(0xff999999),
                                    fontSize: 11.sp,
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                        Container(
                          width: 50.r,
                          alignment: Alignment.center,
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              Container(
                                alignment: Alignment.topRight,
                                height: 20.r,
                                child: Text(
                                  md.msg.time,
                                  style: TextStyle(
                                    color: const Color(0xff999999),
                                    fontSize: 10.sp,
                                  ),
                                ),
                              ),
                              Container(
                                alignment: Alignment.centerRight,
                                height: 20.r,
                                child: md.msg.isRemind
                                    ? Icon(
                                        Icons.timer_off_sharp,
                                        color: const Color(0xff999999),
                                        size: 15.r,
                                      )
                                    : null,
                              ),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            ),
            Container(
              color: const Color(0xffeeeeee),
              height: 0.5,
              margin: EdgeInsets.only(left: 70.r, top: 5.r),
            ),
          ],
        ),
      ),
    );
  }
}
